#include<bits/stdc++.h>
using namespace std;
int a[100001],b[100001],c[100001],d[100001];
vector<pair<int,int>>g;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    scanf("%d",&t);
    while(t--){
        int n,m,l,v;
        scanf("%d%d%d%d",&n,&m,&l,&v);
        g.clear();
        for(int i=0;i<n;i++)
            scanf("%d%d%d",&a[i],&b[i],&c[i]);
        for(int i=0;i<m;i++)
            scanf("%d",&d[i]);
        for(int i=0;i<n;i++){
            if(c[i]<=0&&b[i]<=v)
                continue;
            if(c[i]==0){
                int f=lower_bound(d,d+m,a[i])-d;
                if(f==m)
                    continue;
                g.push_back({m-1,f});
            }
            else if(c[i]>0){
                if(b[i]>v){
                    int f=lower_bound(d,d+m,a[i])-d;
                    if(f==m)
                        continue;
                    g.push_back({m-1,f});
                }
                else if(b[i]==v){
                    int f=upper_bound(d,d+m,a[i])-d;
                    if(f==m)
                        continue;
                    g.push_back({m-1,f});
                }
                else{
                    int h=a[i]+(v*v-b[i]*b[i])/(2*c[i]);
                    int f=upper_bound(d,d+m,h)-d;
                    if(f==m)
                        continue;
                    g.push_back({m-1,f});
                }
            }
            else{
                int h=a[i]+(b[i]*b[i]-v*v+-2*c[i]-1)/(-2*c[i]);
                int f=lower_bound(d,d+m,h)-d;
                int f1=lower_bound(d,d+m,a[i])-d;
                if(f==f1)
                    continue;
                g.push_back({f-1,f1});
            }
        }
        int b=g.size();
        printf("%d ",b);
        sort(g.begin(),g.end());
        int e=-1,a=0;
        for(int i=0,j=0;i<b,j<b;i++){
            while(j<b&&g[j].second<=e)
                j++;
            if(j<b)
                a++;
            e=g[j].first;
        }
        printf("%d\n",m-a);
    }
    return 0;
}